package com.xuecheng.manage_cms.service.impl;

import com.xuecheng.framework.domain.system.SysDictionary;
import com.xuecheng.framework.exception.CustomExcetionCast;
import com.xuecheng.framework.model.response.CommonCode;
import com.xuecheng.manage_cms.dao.SysDictionaryReponsitory;
import com.xuecheng.manage_cms.service.Sys_dictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
@Transactional
public class Sys_dictionaryServiceImpl implements Sys_dictionaryService {
    @Autowired
    SysDictionaryReponsitory sysDictionaryReponsitory;
    /**
     * @Description:  提供词典查询的方法
     * @Param:  dtype
     * @return:  SysDictionary
     * @Author: Mr.Yuan
     * @Date:
     */
    @Override
    public SysDictionary findByDtype(String dtype) {
        if (StringUtils.isEmpty(dtype)) {
            throw CustomExcetionCast.getCusException(CommonCode.INVALIDPARAM);
        }
        SysDictionary sysDictionary = sysDictionaryReponsitory.findByDType(dtype);
        if (sysDictionary == null) {
            throw CustomExcetionCast.getCusException(CommonCode.SERVER_ERROR);
        }
        return sysDictionary;
    }
}
